home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
BUSINESS
/
TAS206.ARJ
/
ARRAYS.TAS
next >
Wrap
Text File
|
1991-01-07
|
3KB
|
50 lines
{ arrays.tas
This example shows how you can do arithmetic operations on
data arrays.
It creates an average of 3 momentum arrays. Then it creates
a 50 day EMA of the average momentum. Then it creates a 20
day EMA of the 50 day EMA.
Thanks to Dan Rembolt for the example.
}
if quote_count>75 then { Only do the following on tickers
containing at least 75 quotes }
BEGIN { use BEGIN to group the following
statements until the next matching
END statment }
mo75 : array; { declare an array named 'mo75' }
mo20 : array; { declare an array named 'mo20' }
mo10 : array; { declare an array named 'mo10' }
mosum : array; { declare an array named 'mosum' }
smoothmo : array; { declare an array named 'smoothmo' }
mo75 := mo(75); { compute the 75 day momentum and place
it in the 'mo75' array }
mo20 := mo(20); { and then the 20 day momentum}
mo10 := mo(10); { and finally the 10 day momentum }
mosum := add(mo75,mo20); { now, add 75 day momentum to 20 day
momentum. Place the result in array
'mosum'}
mosum := add(mosum,mo10); { add the 10 day momentum to 'mosum' array
so that now, 'mosum' contains the sum
of the three momenta}
mosum := divby(mosum,3); { DIVBY divides the first argument (the
array) by the second argument (the
number). So, in this case, mosum will
be the average of the three momentum
arrays previously added}
smoothmo := mov(mosum,50,'E'); { Now, create a 50 day Exponential Moving
Average and place the resulting array
in "smoothmo"}
moma := mov(smoothmo,20,'E'); { And, lastly, create a 20 day EMA of
the 50 day ema of the average of the
three momentum calculations }
writeln(ticker,' ',moma);
{ Alternatively, you can group the function calls together to make
more complex calculations. The above calculation could also be
written as follows:
}
moma := mov(mov(divby(add(add(mo(75),mo(20)),mo(10)),3),50,'e'),20,'e');
writeln(ticker,' ',moma);
END;